package com.hengpeng.itfin.service;

import java.util.Date;

import com.hengpeng.common.exception.ServiceResult;
import com.hengpeng.itfinbase.message.partner.CashRequestMsg;
import com.hengpeng.itfinbase.message.partner.CashResponseMsg;
import com.hengpeng.itfinbase.message.partner.DrawReconciliationResponseMsg;
import com.hengpeng.itfinbase.message.partner.PayRequestMsg;
import com.hengpeng.itfinbase.message.partner.PayResponseMsg;
import com.hengpeng.itfinbase.message.partner.SaveReconciliationResponseMsg;
import com.hengpeng.itfinbase.persist.Payment;

/**
 * <pre>
 * 支付系统服务接口
 * </pre>
 * 
 * @author zhaojitao
 * @version 1.0, 2015-6-4
 */
public interface PaymentService {

    /**
     * <pre>
     * 包装充值请求实体（保存本地充值信息）
     * </pre>
     */
    public void packPayRequest(PayRequestMsg request);

    /**
     * <pre>
     * 处理支付结果
     * </pre>
     * 
     * @param msg
     * @return
     */
    public ServiceResult<Payment> dealPayResult(PayResponseMsg msg);

    /**
     * <pre>
     * 包装取现请求实体（保存本地取现信息）
     * </pre>
     */
    public void packDrawRequest(CashRequestMsg request);

    /**
     * <pre>
     * 处理支付结果
     * </pre>
     * 
     * @param msg
     * @return
     */
    public ServiceResult<Payment> dealDrawResult(CashResponseMsg msg);

    /**
     * <pre>
     * 根据orderId查找充值记录
     * </pre>
     * 
     * @param orderId
     * @return
     */
    public Payment findByOrderId(String orderId);

    /**
     * 取现交易查询
     */
    public void drawQuery();

    /**
     * 充值交易查询
     */
    public void imprestQuery();

    /**
     * <pre>
     * 取现交易查询操作
     * </pre>
     * 
     * @param investInfos
     */
    public void doDrawQuery(Payment payment);

    /**
     * 充值交易查询操作
     * 
     * @param payment
     */
    public void doImprestQuery(Payment payment);

    /**
     * <pre>
     * 根据orderId和ProviderId查找充值记录
     * </pre>
     * 
     * @param orderId
     * @return
     */
    public Payment findByOrderIdAndProviderId(String orderId, String providerId);

    /**
     * <pre>
     * 充值对账
     * </pre>
     * 
     * @param pageNum
     * @param pageSize
     * @param beginDate
     * @param endDate
     */
    public void saveReconciliation(Integer pageNum, Integer pageSize, Date beginDate, Date endDate);

    /**
     * <pre>
     * 充值对账
     * </pre>
     * 
     * @param pageNum
     * @param pageSize
     * @param beginDate
     * @param endDate
     * @return
     */
    public SaveReconciliationResponseMsg doSaveReconciliation(Integer pageNum, Integer pageSize, Date beginDate,
            Date endDate);

    /**
     * <pre>
     * 提现对账
     * </pre>
     * 
     * @param pageNum
     * @param pageSize
     * @param beginDate
     * @param endDate
     */
    public void drawReconciliation(Integer pageNum, Integer pageSize, Date beginDate, Date endDate);

    /**
     * <pre>
     * 提现对账
     * </pre>
     * 
     * @param pageNum
     * @param pageSize
     * @param beginDate
     * @param endDate
     * @return
     */
    public DrawReconciliationResponseMsg doDrawReconciliation(Integer pageNum, Integer pageSize, Date beginDate,
            Date endDate);

    /**
     * 更新提现充值状态
     * 
     * @param oldStatus
     * @param newStatus
     * @param updateTime
     * @param overTime
     * @param chargemoney
     * @param orderId
     * @return
     */
    public int updateStatus(Payment.PayStatus oldStatus, Payment.PayStatus newStatus, Date updateTime, Date overTime,
            Long chargemoney, Long orderId);
}